#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char const *argv[])
{
    int fd;
    char filename[20];
LOOP:
    printf("please input filename:");
    fscanf(stdin,"%s",filename);
    if( (fd=creat(filename,0))==-1)
    {
        printf("\ncreat() fail");
        goto LOOP;
    }else{
        printf("succesful creat\n");
        printf("fd:%d\n",fd);
    }
    char buf[20]="abcde";
    write(fd,buf,sizeof(buf));

    close(fd);
    return 0;
}
